R Markdown

Initiation possible Statistical Analysis for Infertility Perception

Including Plots and Tables of Interest

Perception_propt%>%count(SECTION.A..SOCIO.DEMOGRAPHIC)%>%
  mutate(P_Value=
              recode(SECTION.A..SOCIO.DEMOGRAPHIC,"26-35"="<0.001",
                     "36-45"="<0.001","<25 years"="<0.001",">45"="<0.001"))
##   SECTION.A..SOCIO.DEMOGRAPHIC   n P_Value
## 1                        26-35  90  <0.001
## 2                        36-45 100  <0.001
## 3                    <25 years  37  <0.001
## 4                          >45  31  <0.001

**Multiple Correspondence Analysis (MCA) of respondent to identify similarities or differences

# Multiple Correspondence Analysis (MCA)

Perception_propt[,c(2:26)]%>%MCA(ncp=2,graph=FALSE)%>%
  fviz_mca_biplot(geom="point",repel=TRUE,ggtheme=theme_minimal())

**Again: preliminary test analysis

# Preliminary socio-demographics 

newdat<-Perception_propt%>%mutate(Duration_infertility=
    X6..Duration.of.infertility,yes_no=ifelse(Duration_infertility=="Nil","Fertile","Infertile"))

Perception_propt%>%mutate(Duration_infertility=
  X6..Duration.of.infertility,yes_no=ifelse(
  Duration_infertility=="Nil","Fertile","Infertile"))%>%group_by(yes_no)%>%
  count(age=SECTION.A..SOCIO.DEMOGRAPHIC)%>%
  pivot_wider(names_from = age,values_from = n)%>%
  column_to_rownames(var="yes_no")%>%mutate(p_value="=0.04")
##           26-35 36-45 <25 years >45 p_value
## Fertile      30    24        13   3   =0.04
## Infertile    60    76        24  28   =0.04
# Logistic Regression Analysis
glm(factor(yes_no)~SECTION.A..SOCIO.DEMOGRAPHIC+X2..Gender+X5..Level.of.education,data = newdat,family = "binomial")%>%summary()
## 
## Call:
## glm(formula = factor(yes_no) ~ SECTION.A..SOCIO.DEMOGRAPHIC + 
##     X2..Gender + X5..Level.of.education, family = "binomial", 
##     data = newdat)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -2.1778  -1.2387   0.6834   0.8658   1.1173  
## 
## Coefficients:
##                                   Estimate Std. Error z value Pr(>|z|)   
## (Intercept)                         0.7749     1.1855   0.654  0.51331   
## SECTION.A..SOCIO.DEMOGRAPHIC>45     2.3021     0.7605   3.027  0.00247 **
## SECTION.A..SOCIO.DEMOGRAPHIC26-35   0.5185     0.4528   1.145  0.25214   
## SECTION.A..SOCIO.DEMOGRAPHIC36-45   1.0660     0.4726   2.255  0.02411 * 
## X2..GenderMale                     -0.6452     0.3341  -1.931  0.05344 . 
## X5..Level.of.educationPrimary       0.2293     1.4395   0.159  0.87343   
## X5..Level.of.educationSecondary     0.4325     1.2606   0.343  0.73155   
## X5..Level.of.educationTertiary     -0.5053     1.2004  -0.421  0.67381   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 301.64  on 257  degrees of freedom
## Residual deviance: 284.83  on 250  degrees of freedom
## AIC: 300.83
## 
## Number of Fisher Scoring iterations: 4

Final

Do_Know_Infertility_Start_1Year<-Perception_propt%>%
  mutate(Duration_infertility=recode(X6..Duration.of.infertility,"Nil:"="Nil"),
  yes_no=ifelse(Duration_infertility=="Nil","Fertile","Infertile"))%>%
  group_by(yes_no)%>%
  count(age=X7..Do.you.know.that.infertility.starts.to.count.after.1.year.of.unprotected.sexual.intercourse.with.an.opposite.sex.partner.)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  column_to_rownames(var="age")%>%mutate(p_value=c("0.32",""))

Who_Can_Infertile<-Perception_propt%>%
  mutate(Duration_infertility=recode(X6..Duration.of.infertility,"Nil:"="Nil"),
  yes_no=ifelse(Duration_infertility=="Nil","Fertile","Infertile"))%>%
  group_by(yes_no)%>%count(age=X8..Who.do.you.think.can.be.infertile)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  column_to_rownames(var="age")%>%mutate(p_value=c("0.74","",""))

Who_is_To_Blamed<-Perception_propt%>%
  mutate(Duration_infertility=recode(X6..Duration.of.infertility,"Nil:"="Nil"),
         yes_no=ifelse(Duration_infertility=="Nil","Fertile","Infertile"))%>%
  group_by(yes_no)%>%count(age=X9..Who.is.being.blamed.for.infertility)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  column_to_rownames(var="age")%>%mutate(p_value=c("0.03","","",""))

Primary_Infertility_Can_Affect_Who<-Perception_propt%>%
  mutate(Duration_infertility=recode(X6..Duration.of.infertility,"Nil:"="Nil"),
  yes_no=ifelse(Duration_infertility=="Nil","Fertile","Infertile"))%>%
  group_by(yes_no)%>%count(age=X10..Primary.infertility.can.affect.who)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  column_to_rownames(var="age")%>%mutate(Fertile=str_replace_na(Fertile,"0"))%>%
  mutate(p_value=c("0.55","",""))
Primary_Infertility_Can_Affect_Who$Fertile<-as.integer(Primary_Infertility_Can_Affect_Who$Fertile)

Secondary_Infertility_can_Affect_Who<-Perception_propt%>%
  mutate(Duration_infertility=recode(X6..Duration.of.infertility,"Nil:"="Nil"),
 yes_no=ifelse(Duration_infertility=="Nil","Fertile","Infertile"))%>%
  group_by(yes_no)%>%count(age=X11..Secondary.infertility.can.affect.who)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  column_to_rownames(var="age")%>%mutate(p_value=c("0.50","",""))


Can_Infertility_Treated<-Perception_propt%>%
  mutate(Duration_infertility=recode(X6..Duration.of.infertility,"Nil:"="Nil"),
         yes_no=ifelse(Duration_infertility=="Nil","Fertile","Infertile"))%>%
  group_by(yes_no)%>%count(age=X14..Do.you.think.infertility.can.and.should.be.treated.medically.)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  column_to_rownames(var="age")%>%mutate(p_value=c("0.60","",""))

Causes_of_Infertility<-Perception_propt%>%
  mutate(Duration_infertility=recode(X6..Duration.of.infertility,"Nil:"="Nil"),
         yes_no=ifelse(Duration_infertility=="Nil","Fertile","Infertile"))%>%
  group_by(yes_no)%>%count(age=X15..Who.do.you.think.should.go.for.laboratory.investigation.before.treatment.can.start.)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  column_to_rownames(var="age")%>%mutate(Fertile=str_replace_na(Fertile,"0"),p_value=c("0.48","",""))
Causes_of_Infertility$Fertile<-as.integer(Causes_of_Infertility$Fertile)

Whom_Would_You_Goto<-Perception_propt%>%
  mutate(Duration_infertility=recode(X6..Duration.of.infertility,"Nil:"="Nil"),
         yes_no=ifelse(Duration_infertility=="Nil","Fertile","Infertile"))%>%
  group_by(yes_no)%>%count(age=X16..Whom.would.you.go.to.for.your.treatment.)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  column_to_rownames(var="age")%>%mutate(Fertile=str_replace_na(Fertile,"0"),
                                         p_value=c("0.27","","","",""))
Whom_Would_You_Goto$Fertile<-as.integer(Whom_Would_You_Goto$Fertile)

Social_Acceptability_to_Abortion<-Perception_propt%>%
  mutate(Duration_infertility=recode(X6..Duration.of.infertility,"Nil:"="Nil"),
         yes_no=ifelse(Duration_infertility=="Nil","Fertile","Infertile"))%>%
  group_by(yes_no)%>%count(age=X19..Do.you.think.it.is.socially.acceptable.to.have.a.baby.through.surrogacy.in.Nigeria.)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  column_to_rownames(var="age")%>%mutate(p_value=c("0.015","",""))

Social_Acceptability_to_IVF<-Perception_propt%>%
  mutate(Duration_infertility=recode(X6..Duration.of.infertility,"Nil:"="Nil"),
         yes_no=ifelse(Duration_infertility=="Nil","Fertile","Infertile"))%>%
  group_by(yes_no)%>%count(age=X20..Do.you.think.it.is.socially.acceptable.to.have.a.baby.through.In.vitro.fertilization.in.Nigeria.)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  column_to_rownames(var="age")%>%mutate(p_value=c("0.90","",""))

Negativity_Infertility_on_Gender<-Perception_propt%>%
  mutate(Duration_infertility=recode(X6..Duration.of.infertility,"Nil:"="Nil"),
         yes_no=ifelse(Duration_infertility=="Nil","Fertile","Infertile"))%>%
  group_by(yes_no)%>%count(age=X21..Infertility.has.more.negative.effect.on.who.more.)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  column_to_rownames(var="age")%>%mutate(p_value=c("0.02","",""))


Social_Effect_of_Infertility_On_Gathering<-Perception_propt%>%
  mutate(Duration_infertility=recode(X6..Duration.of.infertility,"Nil:"="Nil"),
         yes_no=ifelse(Duration_infertility=="Nil","Fertile","Infertile"))%>%
  group_by(yes_no)%>%count(age=X23..Do.staying.in.a.gathering.with.people.who.have.a.child.or.children.affect.one.s.social.health.)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  column_to_rownames(var="age")%>%mutate(p_value=c("0.43","",""))


bind_rows(Do_Know_Infertility_Start_1Year=Do_Know_Infertility_Start_1Year,
          Who_Can_Infertile=Who_Can_Infertile,
          Who_is_To_Blamed=Who_is_To_Blamed,
          Primary_Infertility_Can_Affect_Who=Primary_Infertility_Can_Affect_Who,
          Secondary_Infertility_can_Affect_Who=Secondary_Infertility_can_Affect_Who,
          Can_Infertility_Treated=Can_Infertility_Treated,
          Causes_of_Infertility=Causes_of_Infertility,
          Whom_Would_You_Goto=Whom_Would_You_Goto,
          Social_Acceptability_to_Abortion=Social_Acceptability_to_Abortion,
          Social_Acceptability_to_IVF=Social_Acceptability_to_IVF,
          Negativity_Infertility_on_Gender=Negativity_Infertility_on_Gender,
          Social_Effect_of_Infertility_On_Gathering=Social_Effect_of_Infertility_On_Gathering,
          .id = "Variable")
##                                                          Variable Fertile
## No...1                            Do_Know_Infertility_Start_1Year      27
## Yes...2                           Do_Know_Infertility_Start_1Year      46
## Both men and women...3                          Who_Can_Infertile      64
## Men...4                                         Who_Can_Infertile       2
## Women...5                                       Who_Can_Infertile       7
## Both Husband and wife                            Who_is_To_Blamed      22
## Husband                                          Who_is_To_Blamed       1
## Neither Husband or wife                          Who_is_To_Blamed      10
## Wife                                             Who_is_To_Blamed      40
## Both men and wome              Primary_Infertility_Can_Affect_Who      60
## Women...11                     Primary_Infertility_Can_Affect_Who      13
## Men...12                       Primary_Infertility_Can_Affect_Who       0
## Both men and women...13      Secondary_Infertility_can_Affect_Who      57
## Men...14                     Secondary_Infertility_can_Affect_Who       3
## Women...15                   Secondary_Infertility_can_Affect_Who      13
## No...16                                   Can_Infertility_Treated       3
## Not sure...17                             Can_Infertility_Treated       9
## Yes...18                                  Can_Infertility_Treated      61
## Both men and women...19                     Causes_of_Infertility      69
## Women...20                                  Causes_of_Infertility       4
## Men...21                                    Causes_of_Infertility       0
## Faith healers                                 Whom_Would_You_Goto       1
## Gynaecologist                                 Whom_Would_You_Goto      65
## Herbalist                                     Whom_Would_You_Goto       1
## Others:                                       Whom_Would_You_Goto       6
## Self treatment                                Whom_Would_You_Goto       0
## No...27                          Social_Acceptability_to_Abortion      36
## Not sure...28                    Social_Acceptability_to_Abortion      14
## Yes...29                         Social_Acceptability_to_Abortion      23
## No...30                               Social_Acceptability_to_IVF      10
## Not sure...31                         Social_Acceptability_to_IVF      17
## Yes...32                              Social_Acceptability_to_IVF      46
## Both men and women...33          Negativity_Infertility_on_Gender      23
## Men...34                         Negativity_Infertility_on_Gender       4
## Women...35                       Negativity_Infertility_on_Gender      46
## No...36                 Social_Effect_of_Infertility_On_Gathering      14
## Not sure...37           Social_Effect_of_Infertility_On_Gathering      15
## Yes...38                Social_Effect_of_Infertility_On_Gathering      44
##                         Infertile p_value
## No...1                         88    0.32
## Yes...2                        97        
## Both men and women...3        167    0.74
## Men...4                         3        
## Women...5                      15        
## Both Husband and wife          67    0.03
## Husband                         2        
## Neither Husband or wife         5        
## Wife                          111        
## Both men and wome             154    0.55
## Women...11                     27        
## Men...12                        4        
## Both men and women...13       144    0.50
## Men...14                        3        
## Women...15                     38        
## No...16                         5    0.60
## Not sure...17                  19        
## Yes...18                      161        
## Both men and women...19       170    0.48
## Women...20                     10        
## Men...21                        5        
## Faith healers                   5    0.27
## Gynaecologist                 171        
## Herbalist                       1        
## Others:                         5        
## Self treatment                  3        
## No...27                       105   0.015
## Not sure...28                  52        
## Yes...29                       28        
## No...30                        23    0.90
## Not sure...31                  44        
## Yes...32                      118        
## Both men and women...33        88    0.02
## Men...34                        2        
## Women...35                     95        
## No...36                        24    0.43
## Not sure...37                  39        
## Yes...38                      122

Table 2, 3, and 4

age<-Perception_propt%>%
  mutate(Duration_infertility=recode(X6..Duration.of.infertility,"Nil:"="Nil"),yes_no=ifelse(
   Duration_infertility=="Nil","Fertile","Infertile"))%>%group_by(yes_no)%>%
  count(age=SECTION.A..SOCIO.DEMOGRAPHIC)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  column_to_rownames(var="age")%>%mutate(p_value=c("=0.04","","",""))

Gender<-Perception_propt%>%
  mutate(Duration_infertility=recode(X6..Duration.of.infertility,"Nil:"="Nil"),yes_no=ifelse(
 Duration_infertility=="Nil","Fertile","Infertile"))%>%group_by(yes_no)%>%
  count(age=X2..Gender)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  column_to_rownames(var="age")%>%mutate(p_value=c("0.58",""))

Religion<-Perception_propt%>%
  mutate(Duration_infertility=recode(X6..Duration.of.infertility,"Nil:"="Nil"),yes_no=ifelse(
   Duration_infertility=="Nil","Fertile","Infertile"))%>%group_by(yes_no)%>%
  count(age=X3..Religion)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  column_to_rownames(var="age")%>%mutate(p_value=c("0.51",""))

Occupation<-Perception_propt%>%
  mutate(Duration_infertility=recode(X6..Duration.of.infertility,"Nil:"="Nil"),yes_no=ifelse(
  Duration_infertility=="Nil","Fertile","Infertile"))%>%group_by(yes_no)%>%
  count(age=X4..Occupation)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  column_to_rownames(var="age")%>%mutate(Fertile=str_replace_na(Fertile,"0"))%>%
  mutate(p_value=c("=0.03","","","","",""))
Occupation$Fertile<-as.integer(Occupation$Fertile)
Occupation$Infertile<-as.integer(Occupation$Infertile)

Level_Education<-Perception_propt%>%
  mutate(Duration_infertility=recode(X6..Duration.of.infertility,"Nil:"="Nil"),yes_no=ifelse(
  Duration_infertility=="Nil","Fertile","Infertile"))%>%group_by(yes_no)%>%
  count(age=X5..Level.of.education)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  column_to_rownames(var="age")%>%mutate(p_value=c("0.48","","",""))

Duration_of_Infertility<-Perception_propt%>%
  mutate(Duration_infertility=recode(X6..Duration.of.infertility,"Nil:"="Nil"),
  yes_no=ifelse(Duration_infertility=="Nil","Fertile","Infertile"))%>%
  group_by(yes_no)%>%count(age=Duration_infertility)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  column_to_rownames(var="age")%>%
  mutate(Fertile=str_replace_na(Fertile,"0"),
  Infertile=str_replace_na(Infertile,"0"))%>%
  mutate(p_value=c("<0.001","","","",""))
Duration_of_Infertility$Fertile<-as.integer(Duration_of_Infertility$Fertile)
Duration_of_Infertility$Infertile<-as.integer(Duration_of_Infertility$Infertile)
  Fertile<-as.integer(Duration_of_Infertility$Fertile)
bind_rows(Age=age,
      Gender=Gender,
      Religion=Religion,Occupation=Occupation,Level_Education=Level_Education,
      Duration_of_Infertility=Duration_of_Infertility,.id = "Variable")
##                                             Variable Fertile Infertile p_value
## 26-35                                            Age      30        60   =0.04
## 36-45                                            Age      26        74        
## <25 years                                        Age      13        24        
## >45                                              Age       4        27        
## Female                                        Gender      46       124    0.58
## Male                                          Gender      27        61        
## Christian                                   Religion      42        95    0.51
## Muslim                                      Religion      31        90        
## Civil servant                             Occupation       2         4   =0.03
## Civil servant: Public sector              Occupation      18        64        
## Private sector                            Occupation      31        50        
## Self employed                             Occupation      13        42        
## Student                                   Occupation       6         9        
## Unemployed                                Occupation       3        16        
## Informal                             Level_Education       1         3    0.48
## Primary                              Level_Education       2         7        
## Secondary                            Level_Education       6        30        
## Tertiary                             Level_Education      64       145        
## Nil                          Duration_of_Infertility      73         0  <0.001
## 1-5 years                    Duration_of_Infertility       0       104        
## 11-15 years                  Duration_of_Infertility       0        17        
## 16-20 years                  Duration_of_Infertility       0        10        
## 6-10 years                   Duration_of_Infertility       0        54
# Table 2 Knowledge and common misconceptions about factors that 
# may affect sterility

# Common missconception about infertility
Common_MisConcept_About_Infertility<-Perception_propt%>%
  separate(X13..Common.misconception.about.the.causes.of.infertility...Tick.as.many.as.apply.,c("an1","an2","an3","an4"),sep = ";")%>%
  select(an1,an2,an3,an4)%>%head(10)
## Warning: Expected 4 pieces. Additional pieces discarded in 10 rows [19, 26, 36, 51, 58,
## 59, 124, 173, 237, 238].
## Warning: Expected 4 pieces. Missing pieces filled with `NA` in 202 rows [3, 4, 5, 6, 7,
## 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 21, 23, 25, 27, ...].
Common_MisConcept_About_Infertility
##             an1          an2                            an3
## 1       Natural    Spiritual                    Black magic
## 2  Supernatural    Spiritual                    Black magic
## 3     Spiritual         <NA>                           <NA>
## 4     Spiritual  Black magic Curses by ancestors or deities
## 5       Natural Supernatural                      Spiritual
## 6       Natural    Spiritual                    Black magic
## 7     Spiritual  Black magic Curses by ancestors or deities
## 8       Natural Supernatural                    Black magic
## 9     Spiritual  Black magic        Curses from individuals
## 10    Spiritual  Black magic                           <NA>
##                               an4
## 1  Curses by ancestors or deities
## 2  Curses by ancestors or deities
## 3                            <NA>
## 4                            <NA>
## 5                            <NA>
## 6                            <NA>
## 7                            <NA>
## 8  Curses by ancestors or deities
## 9                            <NA>
## 10                           <NA>
# Causes of Infertility Known by Respondent

Causes_Infertility_Known<-Perception_propt%>%
  separate(X12..What.are.the.causes.of.infertility.that.you.know..Tick.as.many.as.apply.,c("an1","an2","an3","an4","an5","an6","an7","an8","an9","an10","an11"),sep = ";")%>%
  select(an1,an2,an3,an4,an5,an6,an7,an8,an9,an10,an11)%>%head(10)
## Warning: Expected 11 pieces. Missing pieces filled with `NA` in 245 rows [3, 5, 6, 7, 8,
## 9, 10, 11, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, ...].
Causes_Infertility_Known
##                            an1                                            an2
## 1    Hormonal imbalance in Men                    Hormonal imbalance in women
## 2  Hormonal imbalance in women History of infection of genital tract in women
## 3    Hormonal imbalance in Men                    Hormonal imbalance in women
## 4    Hormonal imbalance in Men                    Hormonal imbalance in women
## 5    Hormonal imbalance in Men                    Hormonal imbalance in women
## 6  Hormonal imbalance in women  History of infection of genital tract  in men
## 7    Hormonal imbalance in Men                    Hormonal imbalance in women
## 8    Hormonal imbalance in Men                    Hormonal imbalance in women
## 9    Hormonal imbalance in men                    Hormonal imbalance in women
## 10   Hormonal imbalance in men                    Hormonal imbalance in women
##                                               an3
## 1   History of infection of genital tract  in men
## 2                                         Smoking
## 3   History of infection of genital tract  in men
## 4   History of infection of genital tract  in men
## 5   History of infection of genital tract  in men
## 6  History of infection of genital tract in women
## 7   History of infection of genital tract  in men
## 8   History of infection of genital tract  in men
## 9   History of infection of genital tract  in men
## 10  History of infection of genital tract  in men
##                                               an4
## 1  History of infection of genital tract in women
## 2                            Environmental factor
## 3  History of infection of genital tract in women
## 4  History of infection of genital tract in women
## 5  History of infection of genital tract in women
## 6                                         Smoking
## 7  History of infection of genital tract in women
## 8  History of infection of genital tract in women
## 9  History of infection of genital tract in women
## 10 History of infection of genital tract in women
##                                       an5                          an6
## 1                                 Smoking         Environmental factor
## 2  Use of family planning device by women         Psychological stress
## 3                                 Smoking         Environmental factor
## 4  Use of family planning device by women         Psychological stress
## 5                    Environmental factor         Psychological stress
## 6  Use of family planning device by women         Psychological stress
## 7  Use of family planning device by women         Psychological stress
## 8  Use of family planning device by women Obesity in both men and wome
## 9                            Blocked tube                        Drugs
## 10 Use of family planning device by women        Natural (will of God)
##                             an7                          an8
## 1          Psychological stress Obesity in both men and wome
## 2  Obesity in both men and wome        Natural (will of God)
## 3  Obesity in both men and wome                 Blocked tube
## 4  Obesity in both men and wome        Natural (will of God)
## 5  Obesity in both men and wome        Natural (will of God)
## 6  Obesity in both men and wome        Natural (will of God)
## 7  Obesity in both men and wome        Natural (will of God)
## 8         Natural (will of God)       Rhesus incompatibility
## 9                          <NA>                         <NA>
## 10                 Blocked tube                        Drugs
##                       an9         an10  an11
## 1   Natural (will of God) Blocked tube Drugs
## 2  Rhesus incompatibility Blocked tube Drugs
## 3                   Drugs         <NA>  <NA>
## 4  Rhesus incompatibility Blocked tube Drugs
## 5            Blocked tube         <NA>  <NA>
## 6  Rhesus incompatibility Blocked tube  <NA>
## 7            Blocked tube        Drugs  <NA>
## 8            Blocked tube        Drugs  <NA>
## 9                    <NA>         <NA>  <NA>
## 10                   <NA>         <NA>  <NA>
# Awareness of Hormonal Laboratory Investigation in Treatment of Infertility

Awareness_of_Hormonal_Laboratory_Investigation<-Perception_propt%>%
  separate(X17..Are.you.aware.of.these.hormonal.laboratory.investigations.that.can.be.conducted.for.infertility.which.aids.in.the.treatment.in.both.men.and.women...Tick.as.many.as.apply.,c("an1","an2","an3","an4","an5","an6","an7"),sep = ";")%>%
  select(an1,an2,an3,an4,an5,an6,an7)%>%head(10)
## Warning: Expected 7 pieces. Missing pieces filled with `NA` in 227 rows [1, 2, 3, 4, 6,
## 8, 9, 10, 11, 12, 13, 15, 16, 18, 19, 20, 21, 22, 23, 24, ...].
Awareness_of_Hormonal_Laboratory_Investigation
##                                   an1                                an2
## 1            Leutinizing Hormone (LH)                          Prolactin
## 2  Follicle Stimulating Hormone (FSH)                          Prolactin
## 3            Leutinizing Hormone (LH) Follicle Stimulating Hormone (FSH)
## 4  Follicle Stimulating Hormone (FSH)                           Estrogen
## 5            Leutinizing Hormone (LH) Follicle Stimulating Hormone (FSH)
## 6            Leutinizing Hormone (LH) Follicle Stimulating Hormone (FSH)
## 7            Leutinizing Hormone (LH) Follicle Stimulating Hormone (FSH)
## 8            Leutinizing Hormone (LH) Follicle Stimulating Hormone (FSH)
## 9            Leutinizing Hormone (LH) Follicle Stimulating Hormone (FSH)
## 10           Leutinizing Hormone (LH) Follicle Stimulating Hormone (FSH)
##             an3          an4          an5                          an6
## 1      Estrogen Progesterone Testosterone Anti-Mullerian hormone (AMH)
## 2      Estrogen Progesterone Testosterone                         <NA>
## 3     Prolactin     Estrogen Progesterone                 Testosterone
## 4  Progesterone         <NA>         <NA>                         <NA>
## 5     Prolactin     Estrogen Progesterone                 Testosterone
## 6     Prolactin Testosterone         <NA>                         <NA>
## 7     Prolactin     Estrogen Progesterone                 Testosterone
## 8      Estrogen Progesterone Testosterone                         <NA>
## 9          <NA>         <NA>         <NA>                         <NA>
## 10    Prolactin     Estrogen Progesterone                 Testosterone
##                             an7
## 1                          <NA>
## 2                          <NA>
## 3                          <NA>
## 4                          <NA>
## 5  Anti-Mullerian hormone (AMH)
## 6                          <NA>
## 7  Anti-Mullerian hormone (AMH)
## 8                          <NA>
## 9                          <NA>
## 10                         <NA>
Feeling_After_Failing_Conception<-Perception_propt%>%
  separate(X22..How.do.you.feel.when.you.are.not.able.to.conceive.after.1.year.of.unprotected.sexual.intercourse.with.your.partner..Tick.as.many.as.apply.,c("an1","an2","an3","an4","an5"),sep = ";")%>%
  select(an1,an2,an3,an4,an5)%>%head(10)
## Warning: Expected 5 pieces. Missing pieces filled with `NA` in 247 rows [1, 2, 3, 4, 6,
## 7, 8, 9, 10, 11, 12, 13, 15, 16, 17, 20, 21, 22, 23, 24, ...].
Feeling_After_Failing_Conception
##          an1       an2      an3      an4              an5
## 1        Sad Depressed  Anxious Distress             <NA>
## 2        Sad Depressed  Anxious Distress             <NA>
## 3    Anxious      <NA>     <NA>     <NA>             <NA>
## 4        Sad Depressed  Anxious Distress             <NA>
## 5        Sad Depressed  Anxious Distress Suicidal thought
## 6        Sad   Anxious     <NA>     <NA>             <NA>
## 7        Sad Depressed  Anxious Distress             <NA>
## 8  Depressed      <NA>     <NA>     <NA>             <NA>
## 9        Sad Depressed  Anxious Distress             <NA>
## 10       Sad   Anxious Distress     <NA>             <NA>

Table on the knowledge of the various treatment option available (18)

#Treatment Options Known to respondence

Treatment_Options_Know<-Perception_propt%>%
  mutate(Duration_infertility=recode(X6..Duration.of.infertility,"Nil:"="Nil"),
  yes_no=ifelse(Duration_infertility=="Nil","Fertile","Infertile"))%>%
  separate(X18..What.type.of.treatment.options.do.you.know..Tick.as.many.as.apply.,c("an1","an2","an3","an4","an5","an6","an7"),sep = ";")%>%
  select(an1,an2,an3,an4,an5,an6,an7,yes_no)
## Warning: Expected 7 pieces. Additional pieces discarded in 19 rows [1, 3, 5, 8, 14, 20,
## 25, 40, 53, 131, 136, 152, 156, 161, 192, 198, 203, 240, 247].
## Warning: Expected 7 pieces. Missing pieces filled with `NA` in 223 rows [2, 6, 7, 9, 10,
## 11, 12, 13, 15, 16, 17, 18, 19, 22, 23, 24, 26, 27, 28, 29, ...].
# Treatment option of first respondence


treat1<-Treatment_Options_Know%>%group_by(yes_no)%>%
  count(an1)%>%pivot_wider(names_from = yes_no,values_from = n)%>%
  column_to_rownames(var="an1")%>%
  mutate(Fertile=str_replace_na(Fertile,"0"),
         Infertile=str_replace_na(Infertile,"0"),p_value=c("0.16","","","","",""))
 treat1$Fertile<-as.integer(treat1$Fertile)
 treat1$Infertile<-as.integer(treat1$Infertile)
 
 treat2<-Treatment_Options_Know%>%
   group_by(yes_no)%>%
   count(an2)%>%
   pivot_wider(names_from = yes_no,values_from = n)%>%
   mutate(an2=str_replace_na(an2,"Not Selected"),Fertile=str_replace_na(Fertile,"0"),
          Infertile=str_replace_na(Infertile,"0"),p_value=c("0.23","","","","","","",""))%>%
   column_to_rownames(var="an2")
 treat2$Fertile<-as.integer(treat2$Fertile)
 treat2$Infertile<-as.integer(treat2$Infertile)

 treat3<-Treatment_Options_Know%>%
   group_by(yes_no)%>%
   count(an3)%>%
   pivot_wider(names_from = yes_no,values_from = n)%>%
   mutate(an3=str_replace_na(an3,"Not Selected"),Fertile=str_replace_na(Fertile,"0"),
          Infertile=str_replace_na(Infertile,"0"),p_value=c("0.03","","","","","","",""))%>%
   column_to_rownames(var="an3")
 treat3$Fertile<-as.integer(treat3$Fertile)
 treat3$Infertile<-as.integer(treat3$Infertile)
 
 treat4<-Treatment_Options_Know%>%
   group_by(yes_no)%>%
   count(an4)%>%
   pivot_wider(names_from = yes_no,values_from = n)%>%
   mutate(an4=str_replace_na(an4,"Not Selected"),Fertile=str_replace_na(Fertile,"0"),
          Infertile=str_replace_na(Infertile,"0"),p_value=c("0.14","","","","","",""))%>%
   column_to_rownames(var="an4")
 treat4$Fertile<-as.integer(treat4$Fertile)
 treat4$Infertile<-as.integer(treat4$Infertile)
 
 treat5<-Treatment_Options_Know%>%
   group_by(yes_no)%>%
   count(an5)%>%
   pivot_wider(names_from = yes_no,values_from = n)%>%
   mutate(an5=str_replace_na(an5,"Not Selected"),Fertile=str_replace_na(Fertile,"0"),
          Infertile=str_replace_na(Infertile,"0"),p_value=c("0.14","","","","","",""))%>%
   column_to_rownames(var="an5")
 treat5$Fertile<-as.integer(treat5$Fertile)
 treat5$Infertile<-as.integer(treat5$Infertile)
 
 treat6<-Treatment_Options_Know%>%
   group_by(yes_no)%>%
   count(an6)%>%
   pivot_wider(names_from = yes_no,values_from = n)%>%
   mutate(an6=str_replace_na(an6,"Not Selected"),Fertile=str_replace_na(Fertile,"0"),
          Infertile=str_replace_na(Infertile,"0"),p_value=c("0.52","","","","","",""))%>%
   column_to_rownames(var="an6")
 treat6$Fertile<-as.integer(treat6$Fertile)
 treat6$Infertile<-as.integer(treat6$Infertile)
 
 treat7<-Treatment_Options_Know%>%
   group_by(yes_no)%>%
   count(an7)%>%
   pivot_wider(names_from = yes_no,values_from = n)%>%
   mutate(an7=str_replace_na(an7,"Not Selected"),Fertile=str_replace_na(Fertile,"0"),
          Infertile=str_replace_na(Infertile,"0"),p_value=c("0.04","","","",""))%>%
   column_to_rownames(var="an7")
 treat7$Fertile<-as.integer(treat7$Fertile)
 treat7$Infertile<-as.integer(treat7$Infertile)
 bind_rows(ans_1=treat1,ans_2=treat2,ans_3=treat3,
           ans_4=treat4,ans_5=treat5,ans_6=treat6,ans_7=treat7,.id = "Variables") 
##                                             Variables Fertile Infertile p_value
## In-vito fertilization (IVF)...1                 ans_1       7        14    0.16
## Intra uterine insemination (IUI)...2            ans_1       2         0        
## Intracytoplasmic sperm injection (ICS)...3      ans_1       1         0        
## Sperm donor...4                                 ans_1       2         6        
## Use of medication (Hormonal drugs)              ans_1      61       164        
## Surrogacy...6                                   ans_1       0         1        
## In-vito fertilization (IVF)...7                 ans_2      45       133    0.23
## Laparascopic/hysteroscopic surgery...8          ans_2       2         1        
## Ova donor...9                                   ans_2       2         3        
## Sperm donor...10                                ans_2       8        15        
## Surrogacy...11                                  ans_2       2         2        
## Varicocelectomy...12                            ans_2       1         0        
## Not Selected...13                               ans_2      13        30        
## Intra uterine insemination (IUI)...14           ans_2       0         1        
## Intracytoplasmic sperm injection (ICS)...15     ans_3       2         0    0.03
## Laparascopic/hysteroscopic surgery...16         ans_3       2        14        
## Ova donor...17                                  ans_3       6        13        
## Sperm donor...18                                ans_3      34        56        
## Surrogacy...19                                  ans_3       8        29        
## Not Selected...20                               ans_3      21        62        
## Intra uterine insemination (IUI)...21           ans_3       0         1        
## Varicocelectomy...22                            ans_3       0        10        
## Intra uterine insemination (IUI)...23           ans_4       4         6    0.14
## Laparascopic/hysteroscopic surgery...24         ans_4       2        17        
## Ova donor...25                                  ans_4      22        41        
## Ovarian stimulation...26                        ans_4       1         0        
## Surrogacy...27                                  ans_4      13        25        
## Varicocelectomy...28                            ans_4       1         9        
## Not Selected...29                               ans_4      30        87        
## Intra uterine insemination (IUI)...30           ans_5       5        10    0.14
## Intracytoplasmic sperm injection (ICS)...31     ans_5       2         0        
## Laparascopic/hysteroscopic surgery...32         ans_5       1        13        
## Surrogacy...33                                  ans_5      20        34        
## Not Selected...34                               ans_5      45       121        
## Ovarian stimulation...35                        ans_5       0         1        
## Varicocelectomy...36                            ans_5       0         6        
## Intra uterine insemination (IUI)...37           ans_6      13        20    0.52
## Laparascopic/hysteroscopic surgery...38         ans_6       3         5        
## Ovarian stimulation...39                        ans_6       2         3        
## Not Selected...40                               ans_6      55       149        
## Intracytoplasmic sperm injection (ICS)...41     ans_6       0         1        
## Tubal surgeries                                 ans_6       0         1        
## Varicocelectomy...43                            ans_6       0         6        
## Intra uterine insemination (IUI)...44           ans_7       2         3    0.04
## Intracytoplasmic sperm injection (ICS)...45     ans_7       7         2        
## Laparascopic/hysteroscopic surgery...46         ans_7       2         6        
## Varicocelectomy...47                            ans_7       2        11        
## Not Selected...48                               ans_7      60       163
# Table 2 Knowledge and common misconceptions about factors that may affect sterility

# Common misconception about infertility
Common_MisConcept_About_Infertility<-Perception_propt%>%
  mutate(Duration_infertility=recode(X6..Duration.of.infertility,"Nil:"="Nil"), yes_no=ifelse(Duration_infertility=="Nil","Fertile","Infertile"))%>%
  separate(X13..Common.misconception.about.the.causes.of.infertility...Tick.as.many.as.apply.,c("an1","an2","an3","an4"),sep = ";")%>%
  select(an1,an2,an3,an4,yes_no)
## Warning: Expected 4 pieces. Additional pieces discarded in 10 rows [19, 26, 36, 51, 58,
## 59, 124, 173, 237, 238].
## Warning: Expected 4 pieces. Missing pieces filled with `NA` in 202 rows [3, 4, 5, 6, 7,
## 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 21, 23, 25, 27, ...].
trt1<-Common_MisConcept_About_Infertility%>%group_by(yes_no)%>%
  count(an1)%>%pivot_wider(names_from = yes_no,values_from = n)%>%
  column_to_rownames(var="an1")%>%
  mutate(Fertile=str_replace_na(Fertile,"0"),Infertile=str_replace_na(Infertile,"0"),p_value=c("0.10","","","","",""))
trt1$Fertile<-as.integer(trt1$Fertile)
trt1$Infertile<-as.integer(trt1$Infertile)

trt2<-Common_MisConcept_About_Infertility%>%
  group_by(yes_no)%>%
  count(an2)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  mutate(an2=str_replace_na(an2,"Not Selected"),Fertile=str_replace_na(Fertile,"0"),Infertile=str_replace_na(Infertile,"0"),p_value=c("0.06","","","","",""))%>%column_to_rownames(var="an2")
trt2$Fertile<-as.integer(trt2$Fertile)
trt2$Infertile<-as.integer(trt2$Infertile)

trt3<-Common_MisConcept_About_Infertility%>%
  group_by(yes_no)%>%
  count(an3)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  mutate(an3=str_replace_na(an3,"Not Selected"),Fertile=str_replace_na(Fertile,"0"),Infertile=str_replace_na(Infertile,"0"),p_value=c("0.45","","","","",""))%>%column_to_rownames(var="an3")
trt3$Fertile<-as.integer(trt3$Fertile)
trt3$Infertile<-as.integer(trt3$Infertile)

trt4<-Common_MisConcept_About_Infertility%>%
  group_by(yes_no)%>%
  count(an4)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  mutate(an4=str_replace_na(an4,"Not Selected"),Fertile=str_replace_na(Fertile,"0"),Infertile=str_replace_na(Infertile,"0"),p_value=c("0.31","","",""))%>%column_to_rownames(var="an4")
trt4$Fertile<-as.integer(trt4$Fertile)
trt4$Infertile<-as.integer(trt4$Infertile)

Misconception_Infertility<-bind_rows(ans_1=trt1,ans_2=trt2,ans_3=trt3,
ans_4=trt4,.id = "Variables")

Misconception_Infertility
##                                     Variables Fertile Infertile p_value
## Black magic...1                         ans_1       3         5    0.10
## Curses from individuals...2             ans_1       2         3        
## Natural                                 ans_1      38        88        
## Others:...4                             ans_1       1         0        
## Spiritual...5                           ans_1      28        89        
## Supernatural...6                        ans_1       1         0        
## Black magic...7                         ans_2      18        58    0.06
## Curses from individuals...8             ans_2      10        32        
## Others:...9                             ans_2       1         0        
## Spiritual...10                          ans_2      29        76        
## Supernatural...11                       ans_2       1         1        
## Not Selected...12                       ans_2      14        18        
## Black magic...13                        ans_3      26        46    0.45
## Curses from individuals...14            ans_3      13        61        
## Others:...15                            ans_3       2         0        
## Not Selected...16                       ans_3      32        75        
## Curses by ancestors or deities...17     ans_3       0         2        
## Spiritual...18                          ans_3       0         1        
## Curses by ancestors or deities...19     ans_4       3         0    0.31
## Curses from individuals...20            ans_4      19        30        
## Others:...21                            ans_4       1         3        
## Not Selected...22                       ans_4      50       152
circles1<-Misconception_Infertility%>%rownames_to_column("Treatment_Option")%>%select(-Variables,-p_value )%>%mutate(Treatment_Option=str_replace_all(Treatment_Option,"[...]\\d*",""),Treatment_Option=recode(Treatment_Option,"Obesity in both men and wome"="Obesity in both men and women"))%>%group_by(Treatment_Option)%>%
  summarise(Fertile=sum(Fertile),Infertile=sum(Infertile))

library(plotly)
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
library(ggpubr)
fig <- plot_ly(circles1, labels = ~Treatment_Option, values = ~Infertile, type = 'pie')
fig1 <- fig %>% layout(title = 'Treatment Options Known to Infertile Respondent', xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))

fig1
figa <- plot_ly(circles1, labels = ~Treatment_Option, values = ~Fertile, type = 'pie')
fig <- figa %>% layout(title = 'Treatment Options Known to Fertile Respondent',xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))
fig
### **Causes of Infertility Known by Respondent**

Causes_Infertility_Known<-Perception_propt%>%
  mutate(Duration_infertility=recode(X6..Duration.of.infertility,"Nil:"="Nil"),
 yes_no=ifelse(Duration_infertility=="Nil","Fertile","Infertile"))%>%
  separate(X12..What.are.the.causes.of.infertility.that.you.know..Tick.as.many.as.apply.,c("an1","an2","an3","an4","an5","an6","an7","an8","an9","an10","an11"),sep = ";")%>%
  select(an1,an2,an3,an4,an5,an6,an7,an8,an9,an10,an11,yes_no)
## Warning: Expected 11 pieces. Missing pieces filled with `NA` in 245 rows [3, 5, 6, 7, 8,
## 9, 10, 11, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, ...].
treta1<-Causes_Infertility_Known%>%group_by(yes_no)%>%
  count(an1)%>%pivot_wider(names_from = yes_no,values_from = n)%>%
  column_to_rownames(var="an1")%>%
  mutate(Fertile=str_replace_na(Fertile,"0"),
  Infertile=str_replace_na(Infertile,"0"),p_value=c("<0.001","","","","","","","","","",""))
treta1$Fertile<-as.integer(treta1$Fertile)
treta1$Infertile<-as.integer(treta1$Infertile)

treta2<-Causes_Infertility_Known%>%
  group_by(yes_no)%>%
  count(an2)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  mutate(an2=str_replace_na(an2,"Not Selected"),Fertile=str_replace_na(Fertile,"0"),
         Infertile=str_replace_na(Infertile,"0"),
         p_value=c("0.62","","","","","","","","",""))%>%column_to_rownames(var="an2")
treta2$Fertile<-as.integer(treta2$Fertile)
treta2$Infertile<-as.integer(treta2$Infertile)

treta3<-Causes_Infertility_Known%>%
  group_by(yes_no)%>%
  count(an3)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  mutate(an3=str_replace_na(an3,"Not Selected"),Fertile=str_replace_na(Fertile,"0"),
         Infertile=str_replace_na(Infertile,"0"),p_value=c("<0.21","","","","","","","","","",""))%>%
  column_to_rownames(var="an3")
treta3$Fertile<-as.integer(treta3$Fertile)
treta3$Infertile<-as.integer(treta3$Infertile)

# Error in fisher.test(.) : 
#  FEXACT error 7(location). LDSTP=18600 is too small for this problem,
# (pastp=39.6896, ipn_0:=ipoin[itp=336]=4340, stp[ipn_0]=39.0949).
# Increase workspace or consider using 'simulate.p.value=TRUE'

treta4<-Causes_Infertility_Known%>%
  group_by(yes_no)%>%
  count(an4)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  mutate(an4=str_replace_na(an4,"Not Selected"),Fertile=str_replace_na(Fertile,"0"),
         Infertile=str_replace_na(Infertile,"0"),p_value=c("0.09","","","","","","","","",""))%>%
  column_to_rownames(var="an4")
treta4$Fertile<-as.integer(treta4$Fertile)
treta4$Infertile<-as.integer(treta4$Infertile)

treta5<-Causes_Infertility_Known%>%
  group_by(yes_no)%>%
  count(an5)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  mutate(an5=str_replace_na(an5,"Not Selected"),Fertile=str_replace_na(Fertile,"0"),
         Infertile=str_replace_na(Infertile,"0"),p_value=c("0.09","","","","","","","",""))%>%
  column_to_rownames(var="an5")
treta5$Fertile<-as.integer(treta5$Fertile)
treta5$Infertile<-as.integer(treta5$Infertile)

treta6<-Causes_Infertility_Known%>%
  group_by(yes_no)%>%
  count(an6)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  mutate(an6=str_replace_na(an6,"Not Selected"),Fertile=str_replace_na(Fertile,"0"),
         Infertile=str_replace_na(Infertile,"0"),p_value=c("0.26","","","","","","","",""))%>%
  column_to_rownames(var="an6")
treta6$Fertile<-as.integer(treta6$Fertile)
treta6$Infertile<-as.integer(treta6$Infertile)

treta7<-Causes_Infertility_Known%>%
  group_by(yes_no)%>%
  count(an7)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  mutate(an7=str_replace_na(an7,"Not Selected"),Fertile=str_replace_na(Fertile,"0"),
         Infertile=str_replace_na(Infertile,"0"),p_value=c("0.39","","","","","",""))%>%
  column_to_rownames(var="an7")
treta7$Fertile<-as.integer(treta7$Fertile)
treta7$Infertile<-as.integer(treta7$Infertile)

treta8<-Causes_Infertility_Known%>%
  group_by(yes_no)%>%
  count(an8)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  mutate(an8=str_replace_na(an8,"Not Selected"),Fertile=str_replace_na(Fertile,"0"),
         Infertile=str_replace_na(Infertile,"0"),p_value=c("0.15","","","","","",""))%>%
  column_to_rownames(var="an8")
treta8$Fertile<-as.integer(treta8$Fertile)
treta8$Infertile<-as.integer(treta8$Infertile)

treta9<-Causes_Infertility_Known%>%
  group_by(yes_no)%>%
  count(an9)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  mutate(an9=str_replace_na(an9,"Not Selected"),Fertile=str_replace_na(Fertile,"0"),
         Infertile=str_replace_na(Infertile,"0"),p_value=c("0.19","","","",""))%>%
  column_to_rownames(var="an9")
treta9$Fertile<-as.integer(treta9$Fertile)
treta9$Infertile<-as.integer(treta9$Infertile)

treta10<-Causes_Infertility_Known%>%
  group_by(yes_no)%>%
  count(an10)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  mutate(an10=str_replace_na(an10,"Not Selected"),Fertile=str_replace_na(Fertile,"0"),
         Infertile=str_replace_na(Infertile,"0"),p_value=c("0.02","",""))%>%
  column_to_rownames(var="an10")
treta10$Fertile<-as.integer(treta10$Fertile)
treta10$Infertile<-as.integer(treta10$Infertile)

treta11<-Causes_Infertility_Known%>%
  group_by(yes_no)%>%
  count(an11)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  mutate(an11=str_replace_na(an11,"Not Selected"),Fertile=str_replace_na(Fertile,"0"),
         Infertile=str_replace_na(Infertile,"0"),p_value=c("0.53",""))%>%
  column_to_rownames(var="an11")
treta11$Fertile<-as.integer(treta11$Fertile)
treta11$Infertile<-as.integer(treta11$Infertile)



Known_cause<-bind_rows(ans_1=treta1,ans_2=treta2,ans_3=treta3,
                            ans_4=treta4,ans_5=treta5,ans_6=treta6,ans_7=treta7,
                            ans_8=treta8,ans_9=treta9,ans_10=treta10,
                            ans_11=treta11,.id = "Variables") 

Known_cause
##                                                     Variables Fertile Infertile
## Environmental factor...1                                ans_1       1         1
## History of infection of genital tract  in men...2       ans_1       6        29
## History of infection of genital tract in women...3      ans_1       2         1
## Hormonal imbalance in Men                               ans_1       2         4
## Hormonal imbalance in men                               ans_1      46       113
## Hormonal imbalance in women...6                         ans_1       9        29
## Natural (will of God)...7                               ans_1       4         3
## Psychological stress...8                                ans_1       1         1
## Use of family planning device by women...9              ans_1       2         1
## Blocked tube...10                                       ans_1       0         2
## Drugs...11                                              ans_1       0         1
## Drugs...12                                              ans_2       1         1
## Environmental factor...13                               ans_2       1         2
## History of infection of genital tract  in men...14      ans_2       6        27
## History of infection of genital tract in women...15     ans_2      11        26
## Hormonal imbalance in women...16                        ans_2      46       115
## Natural (will of God)...17                              ans_2       1         3
## Use of family planning device by women...18             ans_2       1         2
## Not Selected...19                                       ans_2       6         6
## Blocked tube...20                                       ans_2       0         2
## Obesity in both men and women...21                      ans_2       0         1
## Drugs...22                                              ans_3       1         4
## Environmental factor...23                               ans_3       3        12
## History of infection of genital tract  in men...24      ans_3      40        91
## History of infection of genital tract in women...25     ans_3       8        25
## Natural (will of God)...26                              ans_3       2        19
## Obesity in both men and women...27                      ans_3       2         1
## Psychological stress...28                               ans_3       1         1
## Smoking...29                                            ans_3       1         0
## Use of family planning device by women...30             ans_3       8        16
## Not Selected...31                                       ans_3       7        13
## Blocked tube...32                                       ans_3       0         3
## Blocked tube...33                                       ans_4       3         4
## Drugs...34                                              ans_4       1        16
## Environmental factor...35                               ans_4       3        10
## History of infection of genital tract in women...36     ans_4      39        88
## Natural (will of God)...37                              ans_4       5        13
## Obesity in both men and women...38                      ans_4       1         2
## Psychological stress...39                               ans_4       9         9
## Use of family planning device by women...40             ans_4       4        17
## Not Selected...41                                       ans_4       8        25
## Smoking...42                                            ans_4       0         1
## Blocked tube...43                                       ans_5       4        11
## Drugs...44                                              ans_5       4        12
## Environmental factor...45                               ans_5      13        21
## Natural (will of God)...46                              ans_5       7        31
## Obesity in both men and women...47                      ans_5       9         5
## Psychological stress...48                               ans_5       6        12
## Smoking...49                                            ans_5       1         1
## Use of family planning device by women...50             ans_5      16        41
## Not Selected...51                                       ans_5      13        51
## Blocked tube...52                                       ans_6      10        24
## Drugs...53                                              ans_6       4        15
## Environmental factor...54                               ans_6       1         1
## Natural (will of God)...55                              ans_6      15        24
## Obesity in both men and wome...56                       ans_6       1         0
## Obesity in both men and women...57                      ans_6       5         6
## Psychological stress...58                               ans_6       7        18
## Use of family planning device by women...59             ans_6      10        17
## Not Selected...60                                       ans_6      20        80
## Blocked tube...61                                       ans_7      14        21
## Drugs...62                                              ans_7       8        24
## Natural (will of God)...63                              ans_7       4        13
## Obesity in both men and wome...64                       ans_7       1         5
## Obesity in both men and women...65                      ans_7       5         8
## Psychological stress...66                               ans_7      10        13
## Not Selected...67                                       ans_7      31       101
## Blocked tube...68                                       ans_8       4        13
## Drugs...69                                              ans_8      11        21
## Natural (will of God)...70                              ans_8       7        12
## Obesity in both men and wome...71                       ans_8       1         0
## Obesity in both men and women...72                      ans_8       7         8
## Rhesus incompatibility...73                             ans_8       1         0
## Not Selected...74                                       ans_8      42       131
## Blocked tube...75                                       ans_9       9         9
## Drugs...76                                              ans_9       4        14
## Natural (will of God)...77                              ans_9       5         7
## Rhesus incompatibility...78                             ans_9       1         2
## Not Selected...79                                       ans_9      54       153
## Blocked tube...80                                      ans_10       6         9
## Drugs...81                                             ans_10       9         7
## Not Selected...82                                      ans_10      58       169
## Drugs...83                                             ans_11       5         8
## Not Selected...84                                      ans_11      68       177
##                                                     p_value
## Environmental factor...1                             <0.001
## History of infection of genital tract  in men...2          
## History of infection of genital tract in women...3         
## Hormonal imbalance in Men                                  
## Hormonal imbalance in men                                  
## Hormonal imbalance in women...6                            
## Natural (will of God)...7                                  
## Psychological stress...8                                   
## Use of family planning device by women...9                 
## Blocked tube...10                                          
## Drugs...11                                                 
## Drugs...12                                             0.62
## Environmental factor...13                                  
## History of infection of genital tract  in men...14         
## History of infection of genital tract in women...15        
## Hormonal imbalance in women...16                           
## Natural (will of God)...17                                 
## Use of family planning device by women...18                
## Not Selected...19                                          
## Blocked tube...20                                          
## Obesity in both men and women...21                         
## Drugs...22                                            <0.21
## Environmental factor...23                                  
## History of infection of genital tract  in men...24         
## History of infection of genital tract in women...25        
## Natural (will of God)...26                                 
## Obesity in both men and women...27                         
## Psychological stress...28                                  
## Smoking...29                                               
## Use of family planning device by women...30                
## Not Selected...31                                          
## Blocked tube...32                                          
## Blocked tube...33                                      0.09
## Drugs...34                                                 
## Environmental factor...35                                  
## History of infection of genital tract in women...36        
## Natural (will of God)...37                                 
## Obesity in both men and women...38                         
## Psychological stress...39                                  
## Use of family planning device by women...40                
## Not Selected...41                                          
## Smoking...42                                               
## Blocked tube...43                                      0.09
## Drugs...44                                                 
## Environmental factor...45                                  
## Natural (will of God)...46                                 
## Obesity in both men and women...47                         
## Psychological stress...48                                  
## Smoking...49                                               
## Use of family planning device by women...50                
## Not Selected...51                                          
## Blocked tube...52                                      0.26
## Drugs...53                                                 
## Environmental factor...54                                  
## Natural (will of God)...55                                 
## Obesity in both men and wome...56                          
## Obesity in both men and women...57                         
## Psychological stress...58                                  
## Use of family planning device by women...59                
## Not Selected...60                                          
## Blocked tube...61                                      0.39
## Drugs...62                                                 
## Natural (will of God)...63                                 
## Obesity in both men and wome...64                          
## Obesity in both men and women...65                         
## Psychological stress...66                                  
## Not Selected...67                                          
## Blocked tube...68                                      0.15
## Drugs...69                                                 
## Natural (will of God)...70                                 
## Obesity in both men and wome...71                          
## Obesity in both men and women...72                         
## Rhesus incompatibility...73                                
## Not Selected...74                                          
## Blocked tube...75                                      0.19
## Drugs...76                                                 
## Natural (will of God)...77                                 
## Rhesus incompatibility...78                                
## Not Selected...79                                          
## Blocked tube...80                                      0.02
## Drugs...81                                                 
## Not Selected...82                                          
## Drugs...83                                             0.53
## Not Selected...84
circles<-Known_cause%>%rownames_to_column("Treatment_Option")%>%
  select(-Variables,-p_value )%>%mutate(Treatment_Option=str_replace_all(Treatment_Option,"[...]\\d*",""),Treatment_Option=recode(Treatment_Option,"Obesity in both men and wome"="Obesity in both men and women"))%>%group_by(Treatment_Option)%>%
  summarise(Fertile=sum(Fertile),Infertile=sum(Infertile))

library(plotly)
library(ggpubr)
fig2a <- plot_ly(circles, labels = ~Treatment_Option, values = ~Infertile, type = 'pie')
fig2 <- fig2a %>% layout(title = 'Treatment Options Known to Infertile Respondent',
     xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
     yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))

fig2
fig3a <- plot_ly(circles, labels = ~Treatment_Option, values = ~Fertile, type = 'pie')
fig3 <- fig3a %>% layout(title = 'Treatment Options Known to Fertile Respondent',
   xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
   yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))
fig3
ggplot(circles,aes(x="",y=Infertile,fill=Treatment_Option))+
  geom_bar(width = 1,stat = "identity")+coord_polar("y",start = 0)+
  theme_void()+scale_fill_grey()+
  theme(axis.title.x = element_blank())

# Awareness of Hormonal Laboratory Investigation in Treatment of Infertility

Awareness_of_Hormonal_Laboratory_Investigation<-Perception_propt%>%
  mutate(Duration_infertility=recode(X6..Duration.of.infertility,"Nil:"="Nil"),
  yes_no=ifelse(Duration_infertility=="Nil","Fertile","Infertile"))%>%
  separate(X17..Are.you.aware.of.these.hormonal.laboratory.investigations.that.can.be.conducted.for.infertility.which.aids.in.the.treatment.in.both.men.and.women...Tick.as.many.as.apply.,c("an1","an2","an3","an4","an5","an6","an7"),sep = ";")%>%
  select(an1,an2,an3,an4,an5,an6,an7,yes_no)
## Warning: Expected 7 pieces. Missing pieces filled with `NA` in 227 rows [1, 2, 3, 4, 6,
## 8, 9, 10, 11, 12, 13, 15, 16, 18, 19, 20, 21, 22, 23, 24, ...].
tret1<-Awareness_of_Hormonal_Laboratory_Investigation%>%group_by(yes_no)%>%
  count(an1)%>%pivot_wider(names_from = yes_no,values_from = n)%>%
  column_to_rownames(var="an1")%>%
  mutate(Fertile=str_replace_na(Fertile,"0"),Infertile=str_replace_na(Infertile,"0"),p_value=c("0.16","","","","",""))
tret1$Fertile<-as.integer(tret1$Fertile)
tret1$Infertile<-as.integer(tret1$Infertile)

tret2<-Awareness_of_Hormonal_Laboratory_Investigation%>%
  group_by(yes_no)%>%
  count(an2)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  mutate(an2=str_replace_na(an2,"Not Selected"),Fertile=str_replace_na(Fertile,"0"),
  Infertile=str_replace_na(Infertile,"0"),p_value=c("0.01","","","","",""))%>%column_to_rownames(var="an2")
tret2$Fertile<-as.integer(tret2$Fertile)
tret2$Infertile<-as.integer(tret2$Infertile)

tret3<-Awareness_of_Hormonal_Laboratory_Investigation%>%
  group_by(yes_no)%>%
  count(an3)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  mutate(an3=str_replace_na(an3,"Not Selected"),Fertile=str_replace_na(Fertile,"0"),
  Infertile=str_replace_na(Infertile,"0"),p_value=c("<0.001","","","","",""))%>%column_to_rownames(var="an3")
tret3$Fertile<-as.integer(tret3$Fertile)
tret3$Infertile<-as.integer(tret3$Infertile)

tret4<-Awareness_of_Hormonal_Laboratory_Investigation%>%
  group_by(yes_no)%>%
  count(an4)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  mutate(an4=str_replace_na(an4,"Not Selected"),Fertile=str_replace_na(Fertile,"0"),Infertile=str_replace_na(Infertile,"0"),p_value=c("0.18","","","",""))%>%
  column_to_rownames(var="an4")
tret4$Fertile<-as.integer(tret4$Fertile)
tret4$Infertile<-as.integer(tret4$Infertile)

tret5<-Awareness_of_Hormonal_Laboratory_Investigation%>%
  group_by(yes_no)%>%
  count(an5)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  mutate(an5=str_replace_na(an5,"Not Selected"),Fertile=str_replace_na(Fertile,"0"),
         Infertile=str_replace_na(Infertile,"0"),p_value=c("0.02","","",""))%>%column_to_rownames(var="an5")
tret5$Fertile<-as.integer(tret5$Fertile)
tret5$Infertile<-as.integer(tret5$Infertile)

tret6<-Awareness_of_Hormonal_Laboratory_Investigation%>%
  group_by(yes_no)%>%
  count(an6)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  mutate(an6=str_replace_na(an6,"Not Selected"),Fertile=str_replace_na(Fertile,"0"),
         Infertile=str_replace_na(Infertile,"0"),p_value=c("0.18","",""))%>%
  column_to_rownames(var="an6")
tret6$Fertile<-as.integer(tret6$Fertile)
tret6$Infertile<-as.integer(tret6$Infertile)

tret7<-Awareness_of_Hormonal_Laboratory_Investigation%>%
  group_by(yes_no)%>%
  count(an7)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  mutate(an7=str_replace_na(an7,"Not Selected"),Fertile=str_replace_na(Fertile,"0"),
  Infertile=str_replace_na(Infertile,"0"),p_value=c("0.94",""))%>%
  column_to_rownames(var="an7")
tret7$Fertile<-as.integer(tret7$Fertile)
tret7$Infertile<-as.integer(tret7$Infertile)
Treatment_Option<-bind_rows(ans_1=tret1,ans_2=tret2,ans_3=tret3,
                            ans_4=tret4,ans_5=tret5,ans_6=tret6,ans_7=tret7,.id = "Variables") 

circles2<-Treatment_Option%>%rownames_to_column("Treatment_Option")%>%
  select(-Variables,-p_value )%>%mutate(Treatment_Option=str_replace_all(Treatment_Option,"[...]\\d*",""),Treatment_Option=recode(Treatment_Option,"Obesity in both men and wome"="Obesity in both men and women"))%>%group_by(Treatment_Option)%>%
  summarise(Fertile=sum(Fertile),Infertile=sum(Infertile))

fig4a <- plot_ly(circles2, labels = ~Treatment_Option, values = ~Infertile, type = 'pie')
fig4 <- fig4a %>% layout(title = 'Treatment Options Known to Infertile Respondent',xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))

fig4
fig5a <- plot_ly(circles2, labels = ~Treatment_Option, values = ~Fertile, type = 'pie')
fig5 <- fig5a %>% layout(title = 'Treatment Options Known to Fertile Respondent',xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))
fig5
# Feeling After Failing Conception

Feeling_After_Failing_Conception<-Perception_propt%>%
  mutate(Duration_infertility=recode(X6..Duration.of.infertility,"Nil:"="Nil"),
  yes_no=ifelse(Duration_infertility=="Nil","Fertile","Infertile"))%>%
  separate(X22..How.do.you.feel.when.you.are.not.able.to.conceive.after.1.year.of.unprotected.sexual.intercourse.with.your.partner..Tick.as.many.as.apply.,c("an1","an2","an3","an4","an5"),sep = ";")%>%
  select(an1,an2,an3,an4,an5,yes_no)
## Warning: Expected 5 pieces. Missing pieces filled with `NA` in 247 rows [1, 2, 3, 4, 6,
## 7, 8, 9, 10, 11, 12, 13, 15, 16, 17, 20, 21, 22, 23, 24, ...].
trat1<-Feeling_After_Failing_Conception%>%group_by(yes_no)%>%
  count(an1)%>%pivot_wider(names_from = yes_no,values_from = n)%>%
  column_to_rownames(var="an1")%>%
  mutate(Fertile=str_replace_na(Fertile,"0"),
         Infertile=str_replace_na(Infertile,"0"),p_value=c("<0.001","","",""))
trat1$Fertile<-as.integer(trat1$Fertile)
trat1$Infertile<-as.integer(trat1$Infertile)

trat2<-Feeling_After_Failing_Conception%>%
  group_by(yes_no)%>%
  count(an2)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  mutate(an2=str_replace_na(an2,"Not Selected"),Fertile=str_replace_na(Fertile,"0"),
         Infertile=str_replace_na(Infertile,"0"),p_value=c("0.002","","",""))%>%column_to_rownames(var="an2")
trat2$Fertile<-as.integer(trat2$Fertile)
trat2$Infertile<-as.integer(trat2$Infertile)

trat3<-Feeling_After_Failing_Conception%>%
  group_by(yes_no)%>%
  count(an3)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  mutate(an3=str_replace_na(an3,"Not Selected"),Fertile=str_replace_na(Fertile,"0"),
         Infertile=str_replace_na(Infertile,"0"),p_value=c("0.45","","",""))%>%
  column_to_rownames(var="an3")
trat3$Fertile<-as.integer(trat3$Fertile)
trat3$Infertile<-as.integer(trat3$Infertile)

trat4<-Feeling_After_Failing_Conception%>%
  group_by(yes_no)%>%
  count(an4)%>%
  pivot_wider(names_from = yes_no,values_from = n)%>%
  mutate(an4=str_replace_na(an4,"Not Selected"),Fertile=str_replace_na(Fertile,"0"),
         Infertile=str_replace_na(Infertile,"0"),p_value=c("0.25",""))%>%
  column_to_rownames(var="an4")
trat4$Fertile<-as.integer(trat4$Fertile)
trat4$Infertile<-as.integer(trat4$Infertile)

Feeling_Failing<-bind_rows(ans_1=trat1,ans_2=trat2,ans_3=trat3,
                            ans_4=trat4,.id = "Variables") 

circles3<-Feeling_Failing%>%rownames_to_column("Treatment_Option")%>%
  select(-Variables,-p_value )%>%mutate(Treatment_Option=str_replace_all(Treatment_Option,"[...]\\d*",""),Treatment_Option=recode(Treatment_Option,"Obesity in both men and wome"="Obesity in both men and women"))%>%group_by(Treatment_Option)%>%
  summarise(Fertile=sum(Fertile),Infertile=sum(Infertile))

fig6a <- plot_ly(circles3, labels = ~Treatment_Option, values = ~Infertile, type = 'pie')
fig6 <- fig6a %>% layout(title = 'Treatment Options Known to Infertile Respondent',
    xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
     yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))

fig6
fig7a <- plot_ly(circles2, labels = ~Treatment_Option, values = ~Fertile, type = 'pie')
fig7 <- fig7a %>% layout(title = 'Treatment Options Known to Fertile Respondent',
        xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
       yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))
fig7